home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / os2 / xyos2shl.zip / SW.CMD < prev    next >
OS/2 REXX Batch file  |  1996-06-03  |  4KB  |  113 lines

  1. /****
  2.  SW.CMD == SWitch.CMD (REXX) for OS/2 [XYOS2SHL.ZIP]    6/3/96
  3.  SWitch focus between running OS/2 [DOS|WIN3x] processes
  4.  
  5.  SW.CMD calls PMSW.EXE, which is located in BootDrive:/OS2/MDOS
  6.  Usage:   sw.cmd process name mask [/c]
  7.             spaces permitted in "process name mask"
  8.             optional argument "/c" attempts to terminate (EXIT)
  9.               the parent process after focus is SWitched
  10.             special process name "#" = NoOperation
  11. ****/
  12.  
  13. '@echo off'
  14.  
  15. if RxFuncQuery("SysLoadFuncs") then do
  16.   call RxFuncAdd "SysLoadFuncs","RexxUtil","SysLoadFuncs"
  17.   call SysLoadFuncs
  18.   end
  19.  
  20. qexist=rxqueue("create","KILLPROC")
  21. call rxqueue "delete",qexist
  22. if qexist\="KILLPROC" then do
  23.   call rxqueue "delete","KILLPROC"
  24.   exit
  25.   end
  26.  
  27. alias=''
  28. switchtitle=''
  29. quit='no'
  30.  
  31. parse arg alias
  32.  
  33. hlp=translate(alias)
  34. if hlp='?'|hlp='/?'|hlp='-?'|hlp='HELP' then call Help
  35.  
  36. exuent=pos('/C',translate(alias))
  37.  
  38. if exuent>0 then do
  39.   alias=substr(alias,1,exuent-1)
  40.   alias=strip(alias)
  41.   quit='yes'
  42.   end
  43.  
  44. /* ╔═══════════════════════ User Aliases ═════════════════════════╗ */
  45. /* ║  Enter aliases (synonyms) in following form:                 ║ */
  46. /* ║    if alias='' then switchtitle=''           [show TaskList] ║ */
  47. /* ║    if alias='' then switchtitle='#'          [#=NoOperation] ║ */
  48. /* ║    if alias='' then switchtitle='XyWrite'                    ║ */
  49. /* ║    if alias='' then do; switchtitle='XyWin'; quit='yes'; end ║ */
  50. /* ║    if alias='q' then quit='yes' [kill process;show TaskList] ║ */
  51. /* ║    if alias='d' then switchtitle='Desktop'                   ║ */
  52. /* ║    if alias='ed' then switchtitle='editor.exe'               ║ */
  53. /* ║    if alias='w' then switchtitle='XyWin'                     ║ */
  54. /* ║  One alias per line.  Case sEnSiTiVe.                        ║ */
  55. /* FF║---------- DO  ⁿá NOT  ⁿá WRITE  ⁿá ABOVE  ⁿá THIS  ⁿá LINE! -----------║ */
  56. if alias = '' then switchtitle = ''             /* display TaskList */
  57. if alias = 'd' then switchtitle = 'Desktop'
  58. if alias = 'f' then switchtitle = 'FullScreen OS/2 Command Session'
  59. if alias = 'w' then switchtitle = 'XyWin'
  60. if alias = 'x' then switchtitle = 'XyWrite'
  61. if alias = 'p' then switchtitle = 'Post Road Mailer'
  62. if alias = 'f f' then switchtitle = 'FaxWorks Fax Win'
  63. if alias = 'f r' then switchtitle = 'FaxWorks Status Win'
  64. if alias = 'y' then do; switchtitle = 'XyWrite'; quit='yes'; end
  65. /* ║                                                              ║ */
  66. /* ╚══════════════════════════════════════════════════════════════╝ */
  67.  
  68. BootDrive=''
  69. if length(BootDrive)=0 then call Help
  70. SwitchFile=BootDrive||':\OS2\MDOS\PMSW.EXE'
  71.  
  72. /* PMSW return codes */
  73. /* 2=ERROR: error occurred during processing */
  74. /* 1=READY: "/r" switch suppressed focus     */
  75. /* 0=FOCUS: named process given focus        */
  76.  
  77. if switchtitle='' then switchtitle=alias
  78. if switchtitle\=''&switchtitle\='#' then do
  79.   SwitchFile' *'switchtitle'* /r'
  80.   if rc\=1 then signal tl
  81.   SwitchFile' *'switchtitle'*'
  82.   end
  83. else if switchtitle\='#' then do
  84.   tl:
  85.   BootDrive||':\OS2\MDOS\TL.EXE'
  86.   say "No process named ""*"switchtitle"*"" found"
  87.   call Help
  88.   end
  89.  
  90. quit=translate(quit)
  91. if quit='YES' then do
  92.   call rxqueue "create","KILLPROC"
  93.   'exit'
  94.   end
  95. return
  96.  
  97. HELP:
  98.   say
  99.   say 'SW.CMD [XYOS2SHL.ZIP]  R.J.Holmgren  6/3/96'
  100.   say 'SWitch focus between already-running processes,'
  101.   say '  from DOS or OS/2 command lines'
  102.   say
  103.   say 'Usage:  SW process name mask [/C]'
  104.   say '  where process name = title in Ctrl-Esc Task List'
  105.   say '  [/C] terminates calling command line process after focus is SWitched'
  106.   say
  107.   say 'Run INSTALL.CMD to install Xy-OS/2 Shell.'
  108.   say 'SW.CMD calls PMSW.EXE by Bruce E. Högman,'
  109.   say '  which is located in BootDrive:\OS2\MDOS'
  110.   exit
  111. RETURN
  112.  
  113.